@extends('admin.layout.app')

@section('title', '編輯用户')
@section('menu', broute('admin.index'))

@section('content')
<div class="layui-col-lg12">
    <div class="layui-card">
        <div class="layui-card-header">
            編輯{{$admin->name}}
        </div>
        <div class="layui-card-body">
            <form class="layui-form" method="post" action="@broute('admin.update')">
                <div class="layui-form-item">
                    <label class="layui-form-label">ID</label>
                    <input type="hidden" name='id' value="{{$admin->id}}"/>
                    <label class="layui-form-mid layui-word-aux">{{$admin->id}}</span>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">工號</label>
                    <div class="layui-input-block">
                        <input type="text" name="staff_id" lay-verify="required" value="{{$admin->staff_id??''}}" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" value="{{$admin->name??''}}" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">暱稱</label>
                    <div class="layui-input-block">
                        <input type="text" name="nickname" lay-verify="required" value="{{$admin->nickname??''}}" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">分機號</label>
                    <div class="layui-input-block">
                        <input type="text" name="call_id" value="{{$admin->call_id??''}}" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">郵箱</label>
                    <div class="layui-input-block">
                        <input type="text" name="email" value="{{$admin->email??''}}" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">角色</label>
                    <div class="layui-input-block">
                        <select lay-ignore name="roles[]" xm-select="selectIdee" xm-select-search="">
                            @foreach($roles as $role)
                                @if(in_array($role->name,$ownRoles))
                                    <option value="{{$role->id}}" selected>{{$role->name}}</option>
                                @else
                                    <option value="{{$role->id}}" >{{$role->name}}</option>
                                @endif
                            @endforeach
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">啟用</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="enable" lay-skin="switch" @empty($admin->getOriginal('enable')) @else checked @endempty lay-text="ON|OFF" value="1">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit>
                            <i class="layui-icon layui-icon-ok"></i>
                            修改用户
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

@endsection
